package com.gollum.jpa.domain;


import java.io.Serializable;

/**
 * 分页请求对象
 *
 * @author Herther
 * @createTime 2022年09月06日 23:10:00
 * @since 1.0.0
 */
public class PageQueryRequest implements Serializable {

    private Integer page;

    private Integer pageSize;

    private String sorted;

    private String filter;


    public PageQueryRequest(Integer page, Integer pageSize, String sorted, String filter) {
        this.page = page;
        this.pageSize = pageSize;
        this.sorted = sorted;
        this.filter = filter;
    }

    public PageQueryRequest() {
    }

    @Override
    public String toString() {
        return "PageQueryRequest{" +
                "page=" + page +
                ", pageSize=" + pageSize +
                ", sorted='" + sorted + '\'' +
                ", filter='" + filter + '\'' +
                '}';
    }

    public <T> Page<T> toPage(){
        return Page.from(getPage(), getPageSize(),getSorted());
    }

    public Integer getPage() {
        return page;
    }

    public PageQueryRequest setPage(Integer page) {
        this.page = page;
        return this;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public PageQueryRequest setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
        return this;
    }

    public String getSorted() {
        return sorted;
    }

    public PageQueryRequest setSorted(String sorted) {
        this.sorted = sorted;
        return this;
    }

    public String getFilter() {
        return filter;
    }

    public PageQueryRequest setFilter(String filter) {
        this.filter = filter;
        return this;
    }
}
